package com.ycw.controller.guoguo;

import java.awt.image.BufferedImage;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import com.ycw.util.Msg;
import com.ycw.util.VerifyCode;

@Controller
public class VerificationCodeController {

	@RequestMapping("getVerificationCode")
	@ResponseBody
	public Msg getVerificationCode(HttpSession httpSession){

			int width=200;

			int height=69;

			BufferedImage verifyImg=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);

			//生成对应宽高的初始图片

			String randomText = VerifyCode.drawRandomText(width,height,verifyImg);


			httpSession.setAttribute("verifyCode", randomText);



			return Msg.success().add("verifyImg", verifyImg.toString().getBytes());
		}
	}
